/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2023-09-17
 * Time: 22:57
 */
public class Solution {

    /**
     *  二分查找
     */
    public int peakIndexInMountainArray(int[] arr) {
        int len = arr.length;
        int left = 0;
        int right = len - 1;
        while (left < right) {
            int mid = ((right-left)>>1) + left;
            // 比较的是挨着的两个元素
            if (arr[mid] < arr[mid+1]) {
                left = mid + 1;
            } else {
                right = mid;
            }
        }
        return left;
    }
}
